`timescale 1ns / 1ps
//////////////////////////////////////////////////////////////////////////////////
// Company: 
// Engineer: 
// 
// Create Date:    17:54:36 03/31/2014 
// Design Name: 
// Module Name:    display_area 
// Project Name: 
// Target Devices: 
// Tool versions: 
// Description: 
//
// Dependencies: 
//
// Revision: 
// Revision 0.01 - File Created
// Additional Comments: 
//
//////////////////////////////////////////////////////////////////////////////////
module display_area(clk, status, hcounter, vcounter, effective
    );
	 
	 input clk;
	 input [10:0] hcounter, vcounter;
	 input [2:0] status;
	 output effective;
	 
	 reg [10:0] hleft, hright, vtop, vbutt;
	 
	 initial
	 begin
	 hleft = 11'd310;
	 hright = 11'd330;
	 vtop = 11'd440;
	 vbutt = 11'd460;
	 end
	 
	 always@(posedge clk)
	 begin
	 if(status[1])
		begin
		if(hleft>11'd20)
			begin
		   hleft <= hleft - 11'd20;
		   hright <= hright - 11'd20;
			end
		else
			begin
		   hleft <= 11'd0;
		   hright <= 11'd20;
			end
		end
	 else if(status[2])
		begin
		if(hright<11'd620)
			begin
			hleft <= hleft + 11'd20;
			hright <= hright + 11'd20;
			end
		else
			begin
			hleft <= 11'd620;
		   hright <= 11'd640;
			end
		end
	 else
	   begin
		hleft <= hleft;
		hright <= hright;
		end
	 end
	 
	 assign effective = (hcounter > hleft && hcounter <hright && vcounter > vtop && vcounter < vbutt)?1:0;
//assign effective = (hcounter > 11'd20 && hcounter <11'd40 && vcounter > 11'd20 && vcounter < 11'd40)?1:0;

endmodule
